#include <iostream>
using namespace std;

int s[100];
int dp[100];
int next[100]; //1:+ -1:- 0:N/A

#define max(a,b) a>b?a:b
#define INF 0x7F7F7F7F

int main() {
	int n;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> s[i];
	}
	dp[0] = 1;
	next[0] = 0;
	for (int i=1; i<n; i++) {
		dp[i]=1;
		for (int j=0; j<i; j++) {
			if ((s[i]-s[j])*next[j]<0 || j==0) {
				dp[i]=max(dp[i], dp[j]+1);
				next[i]=(s[i]-s[j]>0)?1:-1;
				if (s[i]-s[j]==0) next[i]=0;
			}
		}
	}
	int max = -1;
	for (int i=0; i<n; i++) {
		cout << dp[i] << "\t";
		if (dp[i]>max) max=dp[i];
	}
	cout << endl << max << endl;
	return 0;
}
